package com.econ.powercloud.ems.common.enums;

public enum StatusTypeCode implements EnumMethod {

    GENERAL(1,"普通"),
    ALERT(2, "告警"),
    OPERATION_RECORD(3,"操作记录"),
    EQUIPMENT_OPERATION_STATUS(4,"设备运行状态"),
    DEVICE_COMMUNICATION_STATUS(5,"设备通信状态"),
    FAULT(6,"故障"),
    GATEWAY_COMMUNICATION_STATUS(8,"网关通信状态"),
    OTA_FIRMWARE_UPGRADE_STATUS(9,"ota固件升级状态"),
    PROTECT_EVENT(10,"保护事件");

    private Integer code;
    private String desc;

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }


    StatusTypeCode(int code, String desc){
        this.code=code;
        this.desc=desc;
    }

    public static StatusTypeCode fromCode(int code){
        for(StatusTypeCode type: StatusTypeCode.values()){
            if(type.getCode() == code){
                return type;
            }
        }
        return GENERAL;
    }

    public static boolean judgeAlarmFaultFromCode(int code){
        return StatusTypeCode.ALERT.getCode() == code || StatusTypeCode.FAULT.getCode() == code;
    }

}
